package com.ruoyi.mapper;

import java.util.List;
import com.ruoyi.domain.AdvDevicerelation;
import com.ruoyi.domain.Vo.VoiceVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.web.bind.annotation.PathVariable;

/**
 * 【请填写功能名称】Mapper接口
 *
 * @author ruoyi
 * @date 2024-06-21
 */
public interface AdvDevicerelationMapper
{
    @Delete("delete from  adv_devicerelation ")
    public int clear();


    @Delete("delete from adv_devicerelation   where adv_members_id=#{advMembersId}")
    public int deleteByAdvMembersId(@Param("advMembersId") String advMembersId);
    /**
     * 查询【请填写功能名称】
     *
     * @param advDevicerelationId 【请填写功能名称】主键
     * @return 【请填写功能名称】
     */
    public AdvDevicerelation selectAdvDevicerelationByAdvDevicerelationId(Long advDevicerelationId);

    /**
     * 查询【请填写功能名称】列表
     *
     * @param advDevicerelation 【请填写功能名称】
     * @return 【请填写功能名称】集合
     */
    public List<AdvDevicerelation> selectAdvDevicerelationList(AdvDevicerelation advDevicerelation);

    /**
     * 新增【请填写功能名称】
     *
     * @param advDevicerelation 【请填写功能名称】
     * @return 结果
     */
    public int insertAdvDevicerelation(AdvDevicerelation advDevicerelation);

    /**
     * 修改【请填写功能名称】
     *
     * @param advDevicerelation 【请填写功能名称】
     * @return 结果
     */
    public int updateAdvDevicerelation(AdvDevicerelation advDevicerelation);

    /**
     * 删除【请填写功能名称】
     *
     * @param advDevicerelationId 【请填写功能名称】主键
     * @return 结果
     */
    public int deleteAdvDevicerelationByAdvDevicerelationId(Long advDevicerelationId);

    /**
     * 批量删除【请填写功能名称】
     *
     * @param advDevicerelationIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAdvDevicerelationByAdvDevicerelationIds(Long[] advDevicerelationIds);

    @Delete("delete from adv_devicerelation where " +
            "adv_members_id=#{advMembersId} and devicesno=#{devicesno} and adv_products_id is not null")
    int removeSync(AdvDevicerelation advDevicerelation);

    @Update("update adv_devicerelation set is_choosevideo=0 where devicesno=#{devicesno}")
    int removeAllDefault(@Param("devicesno") String devicesno);

    @Update("update adv_devicerelation set is_choosevideo=1 " +
            "where devicesno=#{devicesno} " +
            "and adv_products_id=#{advProductsId}")
    int setDefault(AdvDevicerelation advDevicerelation);

    @Delete("delete from adv_devicerelation where devicesno=#{devicesno} and adv_broadcast_id=#{advBroadcastId}")
    int removeById(@Param("devicesno") String deviceno, @Param("advBroadcastId") String advBroadcastId);

    @Insert("insert into " +
            "adv_devicerelation(devicesno,adv_members_id,adv_platinfos_id,is_chooseaudio,is_cycle) " +
            "values(#{devicesno}, #{advMembersId}, #{advPlatinfosId}, #{isChooseaudio}, 0)")
    int syncVoice(AdvDevicerelation advDevicerelation);

    @Delete("delete from adv_devicerelation " +
            "where adv_platinfos_id = #{advPlatinfosId} " +
            "and adv_members_id = #{advMembersId} " +
            "and devicesno = #{devicesno}")
    int deleteVoice(AdvDevicerelation advDevicerelation);

    @Update("update adv_devicerelation set is_cycle = 0 " +
            "where adv_platinfos_id = #{advPlatinfosId}  and adv_members_id = #{advMembersId} " +
            "and devicesno = #{devicesno}")
    int cancelCycle(AdvDevicerelation advDevicerelation);

    @Update("update adv_devicerelation set is_cycle = 1 " +
            "where adv_platinfos_id = #{advPlatinfosId}  " +
            "and adv_members_id = #{advMembersId} " +
            "and devicesno = #{devicesno}")
    int setCycle(AdvDevicerelation advDevicerelation);

    @Update("update adv_devicerelation set is_chooseaudio = 0 " +
            "where adv_members_id = #{advMembersId} " +
            "and devicesno = #{devicesno} " +
            "and adv_platinfos_id != #{advPlatinfosId}")
    int cancelDefaultVoice(AdvDevicerelation advDevicerelation);

    @Update("update adv_devicerelation set is_chooseaudio = 1 " +
            "where adv_members_id = #{advMembersId} " +
            "and devicesno = #{devicesno} " +
            "and adv_platinfos_id = #{advPlatinfosId}")
    int setDefaultVoice(AdvDevicerelation advDevicerelation);

    @Update("update adv_devicerelation set is_chooseaudio = 0 " +
            "where adv_members_id = #{advMembersId} " +
            "and devicesno = #{devicesno} " +
            "and adv_platinfos_id = #{advPlatinfosId}")
    int calcelDefaultVoice(AdvDevicerelation advDevicerelation);

    @Update("update  adv_devicerelation set is_choosevideo=0 " +
            "where  devicesno=#{devicesno}")
    int calcelDefaultVideo(@Param("devicesno") String devicesno);


    @Delete("delete from adv_devicerelation where adv_platinfos_id = #{advPlatinfosId}")
    void deleteAdvDevicerelationByAdvPlatinfosId(@Param("advPlatinfosId") Long advPlatinfosId);

    @Update("update  adv_devicerelation set is_choosevideo=1 " +
            "where devicesno=#{id} and adv_products_id =#{defualtProductId}")
    int setDefaultVideo(VoiceVo voiceVo);

    @Update("update  adv_devicerelation set is_chooseaudio=0 " +
            "where  devicesno=#{devicesno}")
    int calcelDefaultAudio(String devicesno);

    @Update("update  adv_devicerelation set is_chooseaudio=1 " +
            "where devicesno=#{id} and adv_platinfos_id =#{defualtProductId}")
    int setDefaultAudio(VoiceVo voiceVo);
}
